With rapid development of the Internet and increasingly rich culture lives of people in both material and spiritual fields, there are growing application requirements for videos, especially high definition videos, in the Internet. However, a data amount of the high definition video is quite large. To ensure that the high definition video can be transmitted over the Internet with limited bandwidth, an issue of compression coding of the high definition video needs to be addressed first.
A video is strongly time-correlated, that is, two adjacent frames of images have many similar image blocks. Therefore, in inter prediction of video encoding, for a current block, motion search is usually performed on a reconstructed frame, to find a block that matches the current block best as a reference block. In a High Efficiency Video Coding (HEVC) standard, there are mainly two types of reference frames: a short-term reference frame and a long-term reference frame. The short-term reference frame is generally a reconstructed frame relatively close to a current reference frame, and has a short-term characteristic of a current frame, for example, has a motion foreground of a shape similar to that of the current frame. The long-term reference frame may be a reconstructed frame relatively far away from the current frame, or may be a reference frame obtained by means of synthesis, and has a long-term characteristic of a video sequence segment, for example, has a background frame of the video sequence segment.
In HEVC, for low-latency configuration with a group of picture (GOP for short) length being 4, currently, the short-term reference frame is usually set by using a tiered quantization parameter (QP for short), but there is no effective method for setting a QP for the long-term reference frame.
Currently, in a technology, corresponding encoding is performed on a background frame according to the following formula (1), to obtain a background long-term reference frame:
                              QP          LT                =                  {                                                    40                                                                                  If                    ⁢                                                                                  ⁢                                          QP                      inter                                                        >                  40                                                                                                      ⌊                                      e                                          0.09                      ×                                              QP                        inter                                                                              ⌋                                                                                                  If                    ⁢                                                                                  ⁢                    20                                    ≤                                      QP                    inter                                    ≤                  40                                                                                    4                                                                                  If                    ⁢                                                                                  ⁢                                          QP                      inter                                                        <                  20                                                                                        (        1        )            
where └ ┘ means a round down operation, QPLT is a QP used for encoding a background frame, and QPinter is a minimum QP for encoding a short-term reference frame: P-frame or B-frame. That is, when the background frame is encoded, the QP for encoding the background frame is obtained according to a quantization parameter for encoding the short-term reference frame: P-frame or B-frame.
In this technology, impact of a video content change is not taken into account when a quantization parameter used for encoding a background frame is determined, and the quantization parameter for encoding the background frame is determined according to only a range of the quantization parameter of the short-term reference frame. As a result, encoding quality is relatively poor when encoding is performed.